package elven.codingit.easysearch.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import elven.codingit.easysearch.model.dto.IndexerResult;
import elven.codingit.easysearch.service.IndexWordService;
import elven.codingit.easyutil.dto.ReturnDto;

/**
 * 搜索关键词
 * @author liuyy
 * @date 2016年8月25日
 */
@Controller
public class SearchController {

	@Autowired
	private IndexWordService service;
	
	@RequestMapping("/dict")
	public String dict(){
		return "/search";
	}
	
	@RequestMapping("/write")
	@ResponseBody
	public ReturnDto write() throws Exception{
		return service.updatePaowordIndex();
	}
	
	@RequestMapping("/search")
	@ResponseBody
	public IndexerResult search(String keyword) throws Exception{
		return service.findbyKeyword(keyword, 10000);
	}
}
